// 日志
var log4js = require('log4js');

log4js.configure({
    appenders: [{
            type: 'console'
        }, // 控制台输出
        {
            type: 'file',
            filename: 'logs/binwh.log',
            maxLogSize: 1024000,
            backups: 3,
            //category: 'normal',
        },
    ],
    replaceConsole: true
});

//var logger = log4js.getLogger('normal'); 
//logger.setLevel('INFO');


exports.logger = function(name) {
    var logger = log4js.getLogger(name);
    logger.setLevel('DEBUG');
    return logger;
}

exports.use = function(app) {
    //页面请求日志,用auto的话,默认级别是WARN
    app.use(log4js.connectLogger(this.logger('app'), {
        level: 'auto',
        format: ':method :url'
    }));
    /*
    app.use(log4js.connectLogger(this.logger('app'), {
        level: log4js.levels.INFO,
        format: ':method :url'
    }));
    */
}